/* eslint-disable react/require-default-props,func-names */
import React from 'react';
import { Router } from 'dva/router';
import PropTypes from 'prop-types';
import IndexPage from './routes/IndexPage';

const cached = {};
function registerModel(app, model) {
  if (!cached[model.namespace]) {
    app.model(model);
    cached[model.namespace] = 1;
  }
}

const Routers = function ({ history, app }) {
  const routes = [
    {
      path: '/',
      getComponent() {
        require.ensure([], (require) => {
          registerModel(app, require('./models/index'));
        }, 'login');
      },
    }, {
      path: '/login',
      getComponent(nextState, cb) {
        require.ensure([], (require) => {
          registerModel(app, require('./models/login'));
          cb(null, require('./routes/login/login'));
        }, 'login');
      },
    }, {
      path: '/indexPage',
      component: IndexPage,
      getIndexRoute(nextState, cb) {
        require.ensure([], (require) => {
          cb(null, { component: require('./routes/IndexPage') });
        }, 'indexPage');
      },
      childRoutes: [
        {
          path: '/commonList',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/commonList/commonList'));
            }, 'commonList');
          },
        }, {
          path: '/elecustomer',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/customerInfo/customerInfo'));
            }, 'customer');
          },
        }, {
          path: '/elematerials',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/materiel/materiel'));
            }, 'materiel');
          },
        }, {
          path: '/eleemployee',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/employee/employee'));
            }, 'employee');
          },
        }, {
          path: '/commonClassify',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/commonClassify/commonClassify'));
            }, 'commonClassify');
          },
        }, {
          path: '/eleproduct',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/printInfo/printInfo'));
            }, 'printInfo');
          },
        }, {
          path: '/syssystemsettings',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/systemSetting/systemSetting'));
            }, 'systemSetting');
          },
        }, {
          path: '/jurisdictionAllot',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/jurisdictionAllot/jurisdictionAllot'));
            }, 'jurisdictionAllot');
          },
        }, {
          path: '/elesupply',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/supplyInfo/supplyInfo'));
            }, 'supplyInfo');
          },
        }, {
          path: '/eleteam',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/teamInfo/teamInfo'));
            }, 'teamInfo');
          },
        }, {
          path: '/eleprocess',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/processInfo/processInfo'));
            }, 'processInfo');
          },
        }, {
          path: '/elemachine',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/machineInfo/machineInfo'));
            }, 'machineInfo');
          },
        }, {
          path: '/elecheckmodel',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/checkModel/checkModel'));
            }, 'elecheckmodel');
          },
        }, {
          path: '/sischeckphase',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/checkPhase/checkPhase'));
            }, 'sischeckphase');
          },
        }, {
          path: '/sftlogininfo',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/sftLoginInfo/sftLoginInfo'));
            }, 'sftLoginInfo');
          },
        }, {
          path: '/sisformula',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/sisFormula/sisFormula'));
            }, 'sisFormula');
          },
        }, {
          path: '/salsalesordermaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/salesOrder/salesOrder'));
            }, 'salesOrder');
          },
        }, {
          path: '/salesOrderSticker',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/salesOrderSticker/salesOrderSticker'));
            }, 'salesOrderSticker');
          },
        }, {
          path: '/salescheckingmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/salesCheckMaster/salesCheckMaster'));
            }, 'salesCheckMaster');
          },
        }, {
          path: '/deliverNotify',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/deliverNotify/deliverNotify'));
            }, 'deliverNotify');
          },
        }, {
          path: '/saldelivergoodsmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/deliverGoods/deliverGoods'));
            }, 'saldelivergoodsmaster');
          },
        }, {
          path: '/salrejectgoodsmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/rejectGoods/rejectGoods'));
            }, 'salrejectgoodsmaster');
          },
        }, {
          path: '/salsalescheckingmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/salesCheck/salesCheck'));
            }, 'salsalescheckingmaster');
          },
        }, {
          path: '/salesInvoice',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/salesInvoice/salesInvoice'));
            }, 'salesInvoice');
          },
        }, {
          path: '/sendCar',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/sendCar/sendCar'));
            }, 'sendCar');
          },
        }, {
          path: '/qualityAbnormal',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/salesManage/qualityAbnormal/qualityAbnormal'));
            }, 'qualityAbnormal');
          },
        }, {
          path: '/siscommonstyle',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/commonStyle/commonStyle'));
            }, 'commonStyle');
          },
        }, {
          path: '/sispayment',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/paymentInfo/paymentInfo'));
            }, 'commonStyle');
          },
        }, {
          path: '/purpurchaseapplymaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/purchaseManage/purchaseApply/purchaseApply'));
            }, 'purpurchaseapplymaster');
          },
        }, {
          path: '/purpurchaseordermaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/purchaseManage/purchaseOrder/purchaseOrder'));
            }, 'purpurchaseordermaster');
          },
        }, {
          path: '/purpurchaseinstoremaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/purchaseManage/purchaseInstore/purchaseInstore'));
            }, 'purpurchaseinstoremaster');
          },
        }, {
          path: '/purpurchasecheckingmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/purchaseManage/purchaseCheck/purchaseCheck'));
            }, 'purpurchasecheckingmaster');
          },
        }, {
          path: '/purpurchaserejectmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/purchaseManage/purchaseReject/purchaseReject'));
            }, 'purpurchaserejectmaster');
          },
        }, {
          path: '/mitproductionmaterialsmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/materialsStock/productionMaterials/productionMaterials'));
            }, 'mitproductionmaterialsmaster');
          },
        }, {
          path: '/mitmaterialsadjustmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/materialsStock/materialsAdjust/materialsAdjust'));
            }, 'mitmaterialsadjustmaster');
          },
        }, {
          path: '/mitmaterialsstoreadjustmentmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/materialsStock/materialsInventoryAdjust/materialsInventoryAdjust'));
            }, 'mitmaterialsstoreadjustmentmaster');
          },
        }, {
          path: '/mitmaterialscheckmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/materialsStock/materialsCheck/materialsCheck'));
            }, 'mitmaterialscheckmaster');
          },
        }, {
          path: '/pitproductinstoremaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/productionInentory/productInstore/productInstore'));
            }, 'pitproductinstoremaster');
          },
        }, {
          path: '/cahfinancialtransfer',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/accountsManage/accountTransfer/accountTransfer'));
            }, 'cahfinancialtransfer');
          },
        }, {
          path: '/cahreceiptmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/accountsManage/cahReceipt/cahReceipt'));
            }, 'cahreceiptmaster');
          },
        }, {
          path: '/opsoutsideprocessmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/outsourceManage/outsideProcess/outsideProcess'));
            }, 'opsoutsideprocessmaster');
          },
        }, {
          path: '/cahpaymentmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/accountsManage/cahPayment/cahPayment'));
            }, 'cahpaymentmaster');
          },
        }, {
          path: '/opsoutsideinstoremaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/outsourceManage/outsideInstore/outsideInstore'));
            }, 'opsoutsideinstoremaster');
          },
        }, {
          path: '/opsoutsidecheckingmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/outsourceManage/purchaseChecking/purchaseChecking'));
            }, 'opsoutsidecheckingmaster');
          },
        }, {
          path: '/mftqualityaccident',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/mftQualityAccident/mftQualityAccident/mftQualityAccident'));
            }, 'mftqualityaccident');
          },
        }, {
          path: '/cahfinancialadjust',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/accountsManage/cahfinancialAdjust/cahfinancialAdjust'));
            }, 'cahfinancialadjust');
          },
        }, {
          path: '/sisprocessclassify',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/sisProcessClassify/sisProcessClassify'));
            }, 'sisprocessclassify');
          },
        }, {
          path: '/pitproductcheckmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/productionInentory/productCheckMaster/productCheckMaster'));
            }, 'pitproductcheckmaster');
          },
        }, {
          path: '/pitproductadjustmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/productionInentory/productAdjustMaster/productAdjustMaster'));
            }, 'pitproductadjustmaster');
          },
        }, {
          path: '/pitproductstoreadjustmentmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/productionInentory/productStoreAdjust/productStoreAdjust'));
            }, 'pitproductstoreadjustmentmaster');
          },
        }, {
          path: '/workorder',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/workOrder/workOrder/workOrder'));
            }, 'workorder');
          },
        }, {
          path: '/processcard',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/workOrder/processcard/processcard'));
            }, 'processcard');
          },
        }, {
          path: '/mftproductionreportmaster',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/mftProductionReportMaster/mftProductionReportMaster/mftProductionReportMaster'));
            }, 'mftproductionreportmaster');
          },
        }, {
          path: '/sisproductclassify',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/productClassify/productClassify'));
            }, 'sisproductclassify');
          },
        }, {
          path: '/commonBill',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/common/commonBill'));
            }, 'commonBill');
          },
        }, {
          path: '/workOrderNew',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/manufacture/workOrder/workOrder'));
            }, 'workOrderNew');
          },
        }, {
          path: '/productionPlan',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/productionPlan/productionPlan'));
            }, 'productionPlan');
          },
        }, {
          path: '/commonChar',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/commonChar/commonChar'));
            }, 'commonChar');
          },
        }, {
          path: '/eleteamInfo',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/common/eleteamInfo'));
            }, 'eleteamInfo');
          },
        }, {
          path: '/sisformulaInfo',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/sisFormula/sisFormulaInfo'));
            }, 'sisformulaInfo');
          },
        }, {
          path: '/elemachineInfo',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/machineInfo/eleMachineInfo'));
            }, 'machineInfo');
          },
        }, {
          path: '/systemPermission',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/systemPermission/systemPermissionInfo'));
            }, 'machineInfo');
          },
        }, {
          path: '/importData',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/importData/importData'));
            }, 'importData');
          },
        }, {
          path: '/sispaymentTerms',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/paymentInfo/paymentInfo'));
            }, 'commonStyle');
          },
        }, {
          path: '/productionReport',
          getComponent(nextState, cb) {
            require.ensure([], (require) => {
              cb(null, require('./routes/basicInfoSetting/productReport/productReport'));
            }, 'productionReport');
          },
        },
      ],
    },
  ];
  return <Router history={history} routes={routes} />;
};
Routers.propTypes = {
  history: PropTypes.object,
  app: PropTypes.object,
};

export default Routers;
